package com.yichen.bean.pojo;

import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * @Classname People
 * @Description
 * @Author caozhenhao001
 * @Date 2024/3/27
 * @Version
 */
@Component
public class People implements BeanNameAware, EnvironmentAware, InitializingBean {

	@Value("王五")
	private String name;
	private String sex;
	private Integer age;
	private String  beanName;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	@Override
	public String toString() {
		return "People{" +
				"name='" + name + '\'' +
				", sex='" + sex + '\'' +
				", age=" + age +
				", beanName='" + beanName + '\'' +
				'}';
	}

	@Override
	public void setBeanName(String name) {
		this.beanName = name;
		System.out.println("---BeanNameAware");
	}

	@Override
	public void setEnvironment(Environment environment) {
		System.out.println("---EnvironmentAware");
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		this.name = "li si";
		System.out.println("---afterPropertiesSet");
	}

}
